//
//  MainTabBarController.m
//  Base
//
//  Created by Teplot_01 on 16/7/12.
//  Copyright © 2016年 Teplot_01. All rights reserved.
//

#import "MainTabBarController.h"
#import "ActivityVC.h"
#import "TravelsVC.h"
#import "TravelVC.h"
#import "CalculationVC.h"
#import "PersonVC.h"
#import "ClubPerson.h"
#import "LenderPersonVC.h"
#import "CalculationForClubVC.h"
#import "CalculationForTouristVC.h"
@interface MainTabBarController ()

@end

@implementation MainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
    ActivityVC *mainVC = [[ActivityVC alloc] init];
    [self addChildVC:mainVC title:@"活动" image:@"tab_huodong_unselected" selectedImage:@"tab_huodong_selected"];
    
    TravelVC *MesVC = [[TravelVC alloc] init];
    [self addChildVC:MesVC title:@"游记" image:@"tab_youji_unselected" selectedImage:@"tab_youji_selected"];
    //此处作用户登录身份的判断
    NSString *str = [NSString readToNSDefaultsWithKey:kType];
    if ([str isEqual:@"0"]) {
        //0为俱乐部用户
        CalculationForClubVC *MoreVC = [[CalculationForClubVC alloc] init];
        [self addChildVC:MoreVC title:@"明算" image:@"tab_mingsuan_unselected" selectedImage:@"tab_mingsuan_selected"];
        ClubPerson *clubPerVC = [[ClubPerson alloc] init];
        [self addChildVC:clubPerVC title:@"我的俱乐部" image:@"tab_wode_unselected" selectedImage:@"tab_wode_selected"];
    }else if ([str isEqual:@"2"]){
        //2为普通用户
        CalculationForTouristVC *MoreVC = [[CalculationForTouristVC alloc] init];
        [self addChildVC:MoreVC title:@"明算" image:@"tab_mingsuan_unselected" selectedImage:@"tab_mingsuan_selected"];
        PersonVC *MeVC = [[PersonVC alloc] init];
        [self addChildVC:MeVC title:@"我的" image:@"tab_wode_unselected" selectedImage:@"tab_wode_selected"];
    }else{
        CalculationVC *MoreVC = [[CalculationVC alloc] init];
        [self addChildVC:MoreVC title:@"明算" image:@"tab_mingsuan_unselected" selectedImage:@"tab_mingsuan_selected"];
        LenderPersonVC *leaderPerVC = [[LenderPersonVC alloc] init];
        [self addChildVC:leaderPerVC title:@"领队" image:@"tab_wode_unselected" selectedImage:@"tab_wode_selected"];
    }
    
}

-(void)addChildVC:(UIViewController *)childVc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage {
    //这句话 可以设置tabbar和navbar 的文字
    childVc.title = title;
    
    childVc.tabBarItem.image = [UIImage imageNamed:image];
    // 声明 这张图片显示出来是原始的样子 不用自动渲染成其他颜色
    childVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    //设置文字样式
    NSMutableDictionary *SelectedtextAttrs = [NSMutableDictionary dictionary];
    SelectedtextAttrs[NSForegroundColorAttributeName] = Theme_Color;//TabBar字体选中时颜色
//    [UIColor colorWithRed:148.0/255.0 green:208.0/255.0 blue:255.0/255.0 alpha:1.0];
    [childVc.tabBarItem setTitleTextAttributes:SelectedtextAttrs forState:UIControlStateSelected];
    
    
    MainNavigationController *nav = [[MainNavigationController alloc] initWithRootViewController:childVc];
//    self.tabBar.translucent = NO;//TabBar是否有阴影 默认是Yes Yes时有效果
    [self addChildViewController:nav];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


@end
